<template>
	<view class="content">
		<!-- 内容 -->
		<view class="box" v-for="(item,index) in villageList" :key="index">
			<view class="boxShuxian"></view>
			<view class="boxContent">
				<view class="boxTop">
					<view class="topLeft">{{item.create_date}}</view>
					<view class="topRight">气表数：{{item.gas_num}}</view>
				</view>
				<view class="boxBottom">
					<view class="bottomLeft">
						<view>气表照片</view>
						<view class="mt10" v-if="item.refuse&&item.status==0">
							原因:{{item.refuse}}
						</view>
					</view>

					<view class="bottomRight">
						<image :src="item.image" @tap="seeimg(item.image)"></image>
					</view>
				</view>
			</view>
			<!-- unqualified -->
			<image v-if="item.status==0" class="unqualified" src="../../static/unqualified.png" mode="widthFix"></image>
			<image v-if="item.status==1" class="unqualified" src="../../static/inreview.png" mode="widthFix"></image>
			<image v-if="item.status==2" class="unqualified" src="../../static/qualified.png" mode="widthFix"></image>
			
		</view>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				token: '',
				username: '',
				password: '',
				// array: ['安装工','检测工','维修工'],
				index: 0,
				userinfo: {},
				value: '', //搜索关键词
				installList: [], //安装列表
				dosearch: false,
				showAcount: false,
				page: 1,
				villageList: [],
				// villageList:[
				// 	{
				// 		date:new Date().getFullYear() + '-' + (new Date().getMonth()+1) + '-' + new Date().getDate(),
				// 		adress:'6854763',
				// 		img:'../../../static/photo2.png'
				// 	},
				// 	{
				// 		date:new Date().getFullYear() + '-' + (new Date().getMonth()+1) + '-' + new Date().getDate(),
				// 		adress:'6854763',
				// 		img:'../../../static/photo2.png'
				// 	},
				// 	{
				// 		date:new Date().getFullYear() + '-' + (new Date().getMonth()+1) + '-' + new Date().getDate(),
				// 		adress:'6854763',
				// 		img:'../../../static/photo2.png'
				// 	}
				// ],
				active: 0,
				last_page: 0
			};
		},
		onLoad() {
			this.villageList = []
			uni.getStorage({
				key: 'token'
			}).then(da => {
				this.token = da[1].data
			})
			setTimeout(() => {
				this.getList()
			}, 10)
		},
		onShow() {

		},
		onPullDownRefresh() {
			this.page = 1
			this.villageList = []
			this.getList();
			// this.getInstallDetail()
		},
		onReachBottom() {
			uni.showLoading({
				title: '加载中'
			})
			this.page++
			if (this.page >= this.last_page) {
				uni.showToast({
					title: '我是有底线的',
					icon: 'none'
				})
				return
			}
			this.getList()
		},
		methods: {
			//图片预览
			seeimg(img) {
				uni.previewImage({
					urls: [img],
					longPressActions: {
						itemList: [],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},
			getList() {
				let that = this
				this.$request.request({
					url: '/outuser/gas_list',
					method: 'GET',
					data: {
						token: that.token,
						page: that.page
					}
				}).then(res => {
					uni.stopPullDownRefresh();
					if (res.data.code == 1) {
						uni.hideLoading()
						res.data.data.data.forEach(item => {

							// item.image=that.$fileImg+item.image
							that.villageList.push(item)
						})
						that.last_page = res.data.data.last_page

						console.log(this.villageList)
					}
				})
			},
			back() {
				uni.navigateBack({
					delta: 1
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background-color: #eee;
	}

	.header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx 30rpx;
		background-color: #fff;

		.header-left {
			display: flex;
			align-items: center;
			font-size: 32rpx;
			font-weight: 500;
			color: #333;

			image {
				width: 28rpx;
				height: 28rpx;
				margin-right: 20rpx;
			}
		}

		.header-right {
			display: flex;
			align-items: center;
			font-size: 28rpx;
			color: #333;

			image {
				width: 52rpx;
				height: 52rpx;
				margin-right: 10rpx;
			}
		}
	}

	.box {
		padding: 20rpx 34rpx;
		background-color: #fff;
		margin: 8rpx 0;
		display: flex;
		position: relative;

		// align-items: center;
		.boxShuxian {
			width: 8rpx;
			height: 28rpx;
			background: #003690;
			border-radius: 4rpx;
			margin-right: 14rpx;
			margin-top: 8rpx;
		}

		.boxContent {
			flex: 1;

			.boxTop {
				width: 100%;
				display: flex;
				justify-content: space-between;

				.topLeft {
					font-size: 32rpx;
					text-align: left;
					color: #333333;
				}

				.topRight {
					font-size: 28rpx;
					text-align: left;
					color: #999999;
				}
			}

			.boxBottom {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 20rpx;
				margin-bottom: 8rpx;

				.bottomLeft {
					font-size: 28rpx;
					text-align: left;
					color: #999999;
				}

				.bottomRight {
					width: 66rpx;
					height: 66rpx;
					background: rgba(0, 0, 0, 0);
					border: 1px solid #e5e5e5;

					image {
						width: 100%;
						height: 100%;
					}
				}
			}
		}

		.unqualified {
			position: absolute;
			left: 50%;
			top: 50%;
			width: 150rpx;
			transform: translateX(-50%) translateY(-50%);
		}
	}
</style>
